﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            float[] f1 = new float[10];
            float[] f2 = new float[10];
            home(f1, f2);
        }

        private static void home(float[] f1, float[] f2)
        {
            Console.WriteLine("用户功能选择：1、存款，2、取款");
            int num = int.Parse(Console.ReadLine());
            switch (num)
            {
                case 1:
                    CK(f1, f2);
                    break;
                case 2:
                    QK(f1, f2);
                    break;
                default:
                    break;
            }
        }

        private static void QK(float[] f1, float[] f2)
        {
            float balance=0;
         

                try
                {
                 Console.WriteLine("请输入你要取款的金额");
                    float q = float.Parse(Console.ReadLine());
                    if (q > f1[0])
                    {
                        throw new ArgumentOutOfRangeException();
                    }
                    else {
                        balance = f1[0] - q;

                    }
                }
                catch (ArgumentOutOfRangeException) {
                    Console.WriteLine("取款金额大于余额，请重新输入");
                    QK(f1, f2);

            }
                catch (Exception e)
                {

                    Console.WriteLine(e.Message + e.Source);
                    throw;
                }
                finally
                {
                    Console.WriteLine("剩余金额为" + balance);
                }


        }

        static void CK(float[] f1, float[] f2)
        {
            float sum = 0;
       
               a: Console.WriteLine("请输入你要存款的金额");
                float c = float.Parse(Console.ReadLine());
                sum = sum + c;
                Console.WriteLine("是否继续存款：是 ，否");
                string str = Console.ReadLine();
                switch (str)
                {
                    case "否":
                        Console.WriteLine("您当前的总金额为" + sum);
                    f1[0] = sum;
                    home(f1, f2);


                    break;
                    case "是":
                    goto a;  
                    break;

                    default:
                        break;
                }
            

        }
    }
}
